survival hw 5

KK书,chapter 3 Practice Exercises KM书 8.1,8.5 1)使用软件built-in函数,完成题目 2)使用自编code,完成题目中的Wald test, Likelihood ratio test 3)使用软件built-in函数,相持计算的argument更换为“exact”、“efron”、“descrete”,重复分析,看看结果差得大不大 R user 可加载下面的包导入数据 library(KMsurv) data(hodg)

KM 8.1

In section 1.10, times to death or relapse (in days) are given for 23 nonHodgkin’s lymphoma (NHL) patients, 11 receiving an allogenic (Allo) transplant from an HLA-matched sibling donor and 12 patients receiving an autologous (Auto) transplant. Also, data on 20 Hodgkin’s lymphoma (HOD) patients, 5 receiving an allogenic (Allo) transplant from an HLAmatched sibling donor and 15 patients receiving an autologous (Auto) transplant is given.

(a) Treating NHL Allo as the baseline hazard function, state the appropriate coding which would allow the investigator to test for any difference in survival functions for the four groups, treating them as four independent groups.

rm(list = ls())
pkgs <- c('tidyverse','skimr','survival','KMsurv')
invisible(lapply(pkgs, function(x) suppressMessages(library(x,character.only = TRUE)) ))

data(hodg)
skim(hodg)
Data summary
Name hodg
Number of rows 43
Number of columns 6
_______________________
Column type frequency:
numeric 6
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
gtype 0 1 1.63 0.49 1 1 2 2.0 2 ▅▁▁▁▇
dtype 0 1 1.47 0.50 1 1 1 2.0 2 ▇▁▁▁▇
time 0 1 429.74 570.54 2 55 132 504.0 2144 ▇▂▁▁▁
delta 0 1 0.60 0.49 0 0 1 1.0 1 ▅▁▁▁▇
score 0 1 76.28 21.05 20 60 80 90.0 100 ▁▂▂▃▇
wtime 0 1 37.70 33.62 5 16 24 55.5 171 ▇▃▂▁▁
hodg$new <- ifelse(hodg$gtype==1 & hodg$dtype==1,'allo_nhl',
                            ifelse(hodg$gtype==2 & hodg$dtype==1,'autlo_nhl',ifelse(hodg$gtype==1 & hodg$dtype==2,'allo_hod','auto_hod'))) %>% factor() %>% relevel(.,ref = "allo_nhl")

model <- coxph(Surv(time,delta)~new,data=hodg,ties = 'breslow')
summary(model)
Call:
coxph(formula = Surv(time, delta) ~ new, data = hodg, ties = "breslow")

  n= 43, number of events= 26 

               coef exp(coef) se(coef)     z Pr(>|z|)   
newallo_hod  1.8297    6.2323   0.6753 2.709  0.00674 **
newautlo_nhl 0.6639    1.9423   0.5643 1.177  0.23939   
newauto_hod  0.1537    1.1662   0.5888 0.261  0.79406   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

             exp(coef) exp(-coef) lower .95 upper .95
newallo_hod      6.232     0.1605    1.6589    23.414
newautlo_nhl     1.942     0.5149    0.6427     5.870
newauto_hod      1.166     0.8575    0.3677     3.698

Concordance= 0.605  (se = 0.061 )
Likelihood ratio test= 7.89  on 3 df,   p=0.05
Wald test            = 9.26  on 3 df,   p=0.03
Score (logrank) test = 11.08  on 3 df,   p=0.01

(b) Treating NHL Allo as the baseline hazard function, state the appropriate coding which would allow the investigator to test for an interaction between type of transplant and disease type using main effects and interaction terms.

model <- coxph(Surv(time,delta)~gtype * dtype,data=hodg,ties = 'breslow')
summary(model)
Call:
coxph(formula = Surv(time, delta) ~ gtype * dtype, data = hodg, 
    ties = "breslow")

  n= 43, number of events= 26 

                coef exp(coef) se(coef)      z Pr(>|z|)   
gtype        3.00377  20.16134  1.30504  2.302  0.02135 * 
dtype        4.16964  64.69233  1.45172  2.872  0.00408 **
gtype:dtype -2.33990   0.09634  0.85168 -2.747  0.00601 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

            exp(coef) exp(-coef) lower .95 upper .95
gtype        20.16134    0.04960   1.56196  260.2361
dtype        64.69233    0.01546   3.75963 1113.1660
gtype:dtype   0.09634   10.38019   0.01815    0.5114

Concordance= 0.605  (se = 0.061 )
Likelihood ratio test= 7.89  on 3 df,   p=0.05
Wald test            = 9.26  on 3 df,   p=0.03
Score (logrank) test = 11.08  on 3 df,   p=0.01

(c) Suppose that we have the following model for the hazard rates in the four groups:

\[\begin{align} h(t|NHL Allo) &= h_0(t) \\ h(t|HOD Allo) &= h_0(t)exp(2) \\ h(t|NHL Auto) &= h_0(t)exp(1.5) \\ h(t|HOD Auto) &= h_0(t)exp(0.5) \\ \end{align}\]

What are the risk coefficients, \(\beta_i\) , i = 1, 2, 3, for the interaction model in part b ?

\[ h(t)=h_0(t)exp(\beta_1Auto + \beta_2 HOD + \beta3 Auto*HOD) \] allo_nhl 0 0

allo_hod 0 1

nhl_auto 1 0

hod__auto 1 1

\[\begin{align} \beta_1 & = 1.5 \\ \beta_2 &= 2 \\ \beta_1 + beta_2 +\beta_3 &= 0.5 \\ \beta_3 &= 0.5-1.5-2 =-3 \end{align}\]

KM 8.5

Using the data set in Exercise 1, using the Breslow method of handling ties,

  1. Analyze the data by performing a global test of no effect of group as defined in Exercise 8.1(a) on survival. Construct an ANOVA table to summarize estimates of the risk coefficients and the results of the one degree of freedom tests for each covariate in the model.
model1 <- coxph(Surv(time,delta)~new,data=hodg,ties = 'breslow')
summary(model)
Call:
coxph(formula = Surv(time, delta) ~ gtype * dtype, data = hodg, 
    ties = "breslow")

  n= 43, number of events= 26 

                coef exp(coef) se(coef)      z Pr(>|z|)   
gtype        3.00377  20.16134  1.30504  2.302  0.02135 * 
dtype        4.16964  64.69233  1.45172  2.872  0.00408 **
gtype:dtype -2.33990   0.09634  0.85168 -2.747  0.00601 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

            exp(coef) exp(-coef) lower .95 upper .95
gtype        20.16134    0.04960   1.56196  260.2361
dtype        64.69233    0.01546   3.75963 1113.1660
gtype:dtype   0.09634   10.38019   0.01815    0.5114

Concordance= 0.605  (se = 0.061 )
Likelihood ratio test= 7.89  on 3 df,   p=0.05
Wald test            = 9.26  on 3 df,   p=0.03
Score (logrank) test = 11.08  on 3 df,   p=0.01
model2 <- coxph(Surv(time, delta) ~ 1, 
              ties="breslow", data = hodg)
anova(model1, model2)
Analysis of Deviance Table
 Cox model: response is  Surv(time, delta)
 Model 1: ~ new
 Model 2: ~ 1
   loglik  Chisq Df Pr(>|Chi|)  
1 -83.350                       
2 -87.298 7.8942  3    0.04825 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# anova(model1)
  1. Repeat part (a) using the coding as described in Exercise 8.1(b). Furthermore, test the hypothesis of disease type by transplant interaction using a likelihood ratio rest based on this coding. Repeat using the Wald test.
model3 <- coxph(Surv(time,delta)~gtype * dtype,data=hodg,ties = 'breslow')
summary(model)
Call:
coxph(formula = Surv(time, delta) ~ gtype * dtype, data = hodg, 
    ties = "breslow")

  n= 43, number of events= 26 

                coef exp(coef) se(coef)      z Pr(>|z|)   
gtype        3.00377  20.16134  1.30504  2.302  0.02135 * 
dtype        4.16964  64.69233  1.45172  2.872  0.00408 **
gtype:dtype -2.33990   0.09634  0.85168 -2.747  0.00601 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

            exp(coef) exp(-coef) lower .95 upper .95
gtype        20.16134    0.04960   1.56196  260.2361
dtype        64.69233    0.01546   3.75963 1113.1660
gtype:dtype   0.09634   10.38019   0.01815    0.5114

Concordance= 0.605  (se = 0.061 )
Likelihood ratio test= 7.89  on 3 df,   p=0.05
Wald test            = 9.26  on 3 df,   p=0.03
Score (logrank) test = 11.08  on 3 df,   p=0.01
anova(model2, model3)
Analysis of Deviance Table
 Cox model: response is  Surv(time, delta)
 Model 1: ~ 1
 Model 2: ~ gtype * dtype
   loglik  Chisq Df Pr(>|Chi|)  
1 -87.298                       
2 -83.350 7.8942  3    0.04825 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  1. Find point estimates and 95% confidence intervals for the relative risk of death for an NHL Auto transplant patient as compared to an NHL Allo transplant patient.
coef(model1)[2]
newautlo_nhl 
    0.663868 
confint(model1)[2, ]
    2.5 %    97.5 % 
-0.442074  1.769810 
  1. Find the p-value of a test of the hypothesis that the hazard rates are the same for HOD Allo transplants and NHL Allo patients, using the Wald test. Repeat a similar test for Auto patients.
library(aod) # wald.test

Attaching package: 'aod'
The following object is masked from 'package:survival':

    rats
wald.test(b = coef(model3), Sigma = vcov(model3), Terms = 1)
Wald test:
----------

Chi-squared test:
X2 = 5.3, df = 1, P(> X2) = 0.021
  1. Test the hypothesis, using the Wald test, that the hazard rates for Auto transplant and Allo transplant patients are the same for each disease group against the alternative that the hazard rates for Auto transplant and Allo transplant patients for at least one group are different using a two-degree of freedom test of H0 : h(t | NHL Allo)  h(t | NHL Auto) and H0 : h(t | HOD Allo)  h(t | HOD Auto).
library(aod) # wald.test
wald.test(b = coef(model3), Sigma = vcov(model3), Terms = 2:3)
Wald test:
----------

Chi-squared test:
X2 = 8.3, df = 2, P(> X2) = 0.016
ws.e <- t(coef(model3)[2:3]-0) %*% solve(vcov(model3)[2:3,2:3]) %*% (coef(model3)[2:3]-0)
pchisq(q = ws.e, df = 2, lower.tail = F)
           [,1]
[1,] 0.01614822